<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript">
	function goPage(pageNo){
		//1:获取表单对象
		var form = document.forms[0];
		form.currentPage.value = pageNo;
		form.submit();
	}
</script>

</head>
<body>
<h1>商品列表</h1>
<a href="/product/input">添加</a>
<form action="/product/list" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="60%">
	<tr>
		<td colspan="6">
			关键字:<input type="text" name="keyword" value="${productQueryObject.keyword}"/>
			最低价格:
			     <input type="text" name="minPrice" value="${productQueryObject.minPrice}"/>
			最高价格:
			     <input type="text" name="maxPrice" value="${productQueryObject.maxPrice}"/>
			<input type="submit" value="查询"/>
		</td>
	</tr>
	<tr>
		<td>编号</td>
		<td>商品名称</td>
		<td>商品价格</td>
		<td>商品品牌</td>
		<td>操作</td>
	</tr>
	<c:forEach items="${pageResult.data}" var="product" varStatus="vs">
		<tr>
			<td>${vs.count}</td>
			<td>${product.name}</td>
			<td>${product.price}</td>
			<td>${product.brand.name}</td>
			<td>
				<a href="/product/del?id=${product.id}">删除</a>
				<a href="/product/input?id=${product.id}">修改</a>
			</td>
		</tr>
	</c:forEach>

	<tr>
		<td colspan="6" align="center">
			<a href="javascript:;" onclick="goPage(1)">首页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.prevPage})">上一页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.nextPage})">下一页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.totalPage})">末页</a>
			每页显示:<select name="pageSize" onchange="goPage(1)">
				<option value ="3" ${pageResult.pageSize == 3 ? 'selected' : ''}>3</option>
				<option value ="5" ${pageResult.pageSize == 5 ? 'selected' : ''}>5</option>
				<option value ="10" ${pageResult.pageSize == 10 ? 'selected' : ''}>10</option>
			</select>
			 ${pageResult.currentPage }/${pageResult.totalPage } 页
			跳转:<input type="text" name="currentPage" style="width: 30px" value="${pageResult.currentPage}">
			<input type="submit" value="GO"/>
		</td>
	</tr>
</table>

</form>
</body>
</html>